package lotteryModel;
//线程实现方法，继承thread

import java.util.Arrays;
import javax.swing.JTextField;


public class MyThread extends Thread{
    JTextField jf;//文本框
    public MyThread(JTextField jf) {
        super();
        this.jf = jf;
    }
    @Override//福利彩票36选7 run方法
    public void run() {//需要和main同步的代码
        while(true){
            int[] ball = new int[7];
            for(int i = 0;i<7;i++) {
                ball[i] = (int) (1+(Math.random()*36));
                for(int j=0;j<i;j++) {
                    if(ball[i]==ball[j]) {
                        i--;
                    }
                }
            }
            Arrays.sort(ball);//从36个数中随机选取7个数
            jf.setText(ball[0]+","+ball[1]+","+ball[2]+","+ball[3]+","+ball[4]+","+ball[5]+","+ball[6]);

        }
    }
}
